package com.vf.admin.client.service.impl;

import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.aliyun.oss.OSSClient;
import com.vf.admin.client.common.ClientConstants;
import com.vf.admin.client.common.RedisKeys;
import com.vf.admin.client.dao.*;
import com.vf.admin.client.dto.RoomMemberDto;
import com.vf.admin.client.service.*;
import com.vf.admin.client.tx.utils.TxIm;
import com.vf.admin.client.tx.vo.UserShiZhi;
import com.vf.admin.common.Constants;
import com.vf.admin.common.entity.Result;
import com.vf.admin.common.redis.RedisUtil;
import com.vf.admin.common.splitpage.SplitPageBean;
import com.vf.admin.fiwork.controller.AppDailyTasController;
import com.vf.admin.miaodong.entity.*;
import com.vf.admin.utils.Base64Image.AliyunOSSClientUtil;
import com.vf.admin.utils.DatesUtil;
import com.vf.admin.utils.RandomUtil;
import com.vf.admin.utils.TimeUtils;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import org.springframework.web.multipart.MultipartFile;

import java.io.ByteArrayInputStream;
import java.math.BigDecimal;
import java.util.*;

import static com.vf.admin.client.tx.utils.TxIm.portraitNiChengSet;
import static com.vf.admin.client.tx.utils.TxIm.portraitTouXiangSet;
import static com.vf.admin.utils.StringEx.isNull;

/**
 * 用户管理
 */
@Service
@Transactional
public class AppUserServiceImpl implements AppUserService {

    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    AppUserDao appUserDao;
    @Autowired
    AppMingXiZuanShiDao appMingXiZuanShiDao;
    @Autowired
    AppMingxiJinbiDao appMingxiJinbiDao;
    @Autowired
    AppMingxiMeilizhiDao appMingxiMeilizhiDao;
    @Autowired
    AppSetupDao appSetupDao;
    @Autowired
    AppInvitationRecordDao appInvitationRecordDao;
    @Autowired
    RedisUtil redisUtil;
    @Autowired
    AppCashWithdrawalDao appCashWithdrawalDao;
    @Autowired
    AppCommentDao appCommentDao;
    @Autowired
    AppCommentDianzanDao appCommentDianzanDao;
    @Autowired
    AppCommentReplyDao appCommentReplyDao;
    @Autowired
    AppDynamicDao appDynamicDao;
    @Autowired
    AppDynamicDianzanDao appDynamicDianzanDao;
    @Autowired
    AppEarningsDao appEarningsDao;
    @Autowired
    AppFansClubDao appFansClubDao;
    @Autowired
    AppFansDao appFansDao;
    @Autowired
    AppFeedbackDao appFeedbackDao;
    @Autowired
    AppFollowDao appFollowDao;
    @Autowired
    AppGameGiftRecordDao appGameGiftRecordDao;
    @Autowired
    AppGiftRewardDao appGiftRewardDao;

    @Autowired
    AppKnapsackDao appKnapsackDao;
    @Autowired
    AppNewDao appNewDao;
    @Autowired
    AppOrderDao appOrderDao;
    @Autowired
    AppQianDaoRecordDao appQianDaoRecordDao;
    @Autowired
    AppRealNameDao appRealNameDao;
    @Autowired
    AppRoomDao appRoomDao;
    @Autowired
    AppSuggestDao appSuggestDao;

    @Autowired
    AppUserDressupDao appUserDressupDao;
    @Autowired
    AppUserLoginRecordDao appUserLoginRecordDao;
    @Autowired
    AppVisitorDao appVisitorDao;
    @Autowired
    AppRoomPaimaiDao appRoomPaimaiDao;
    @Autowired
    AppRoomAdminDao appRoomAdminDao;

    @Autowired
    AppTaskRecordService appTaskRecordService;
    @Autowired
    AppTaskService appTaskService;
    @Autowired
    AppEarningsService appEarningsService;
    @Autowired
    AppDailyTasController dailyTasController;
    @Autowired
    AppPriceSetService priceSetService;
    @Autowired
    AppAuthUserService appAuthUserService;
    @Autowired
    AppAuthUserService authUserService;
    @Autowired
    AppCharmLevelDao appCharmLevelDao;
    @Autowired
    AppUserSettingDao appUserSettingDao;
    @Autowired
    SystemAlertService systemAlertService;
    @Autowired
    DynamicAlertDao dynamicAlertDao;

    @Override
    public List<AppUser> list(Map<String, Object> paraMap, SplitPageBean splitPage) {
        return appUserDao.list(paraMap, splitPage);
    }

    @Override
    public List<AppUser> oneUsers(Integer userId, Integer status, SplitPageBean splitPageBean) {
        return appUserDao.oneUsers(userId, status, splitPageBean);
    }

    @Override
    public List<AppUser> vipExpired() {
        return appUserDao.vipExpired();
    }

    @Override
    public void updateVipExpire(String userIds) {
        appUserDao.updateVipExpire(userIds);
    }

    @Override
    public List<AppUser> getSearch(String sousuo, SplitPageBean page) {
        return appUserDao.getSearch(sousuo, page);
    }

    @Override
    public AppUser get(Integer id) {
        AppUser  user = appUserDao.get(id);
        if (user.getVipEndDate() != null) {
            user.setVip(TimeUtils.afterNow(user.getVipEndDate())? 1: 0);
        }
        return user;
    }

    @Override
    public AppUser gets(Integer id) {
        AppUser user = appUserDao.get(id);
        return user;
    }

    @Override
    public AppUser getUserInfo(Integer id, String loginname, String tengxuncode) {
        AppUser userInfo = appUserDao.getUserInfo(id, loginname, tengxuncode);
        return userInfo;
    }

    @Override
    public AppUser getFromDB(Integer id) {
        return appUserDao.get(id);
    }

    @Override
    public AppUser getByTxCode(Integer txCode) {
        return appUserDao.getByTxCode(txCode);
    }

    @Override
    public AppUser getAndSetAuthStatus(Integer id) {
        AppUser appUser = appUserDao.get(id);

        Integer realAuthStatus = authUserService.infoByUserAndName(id, ClientConstants.UserAuth.REAL_AUTH);
        Integer mobileAuthStatus = authUserService.infoByUserAndName(id, ClientConstants.UserAuth.MOBILE_AUTH);
        Integer realNameAuthStatus = authUserService.infoByUserAndName(id, ClientConstants.UserAuth.REAL_NAME_AUTH);
        Integer eduAuthStatus = authUserService.infoByUserAndName(id, ClientConstants.UserAuth.EDU_AUTH);
        Integer carAuthStatus = authUserService.infoByUserAndName(id, ClientConstants.UserAuth.CAR_AUTH);
        Integer houseAuthStatus = authUserService.infoByUserAndName(id, ClientConstants.UserAuth.HOUSE_AUTH);
        Integer voiceAuthStatus = authUserService.infoByUserAndName(id, ClientConstants.UserAuth.VOICE);

        appUser.setRealAuthStatus(realAuthStatus);
        appUser.setMobileAuthStatus(mobileAuthStatus);
        appUser.setRealNameAuthStatus(realNameAuthStatus);
        appUser.setEduAuthStatus(eduAuthStatus);
        appUser.setCarAuthStatus(carAuthStatus);
        appUser.setHouseAuthStatus(houseAuthStatus);
        appUser.setVoiceAuthStatus(voiceAuthStatus);
        return appUser;
    }

    @Override
    public AppUser lockGet(Integer id) {
        return appUserDao.lockGet(id);
    }

    @Override
    public AppUser getTcOrId(Integer id) {
        return appUserDao.getTcOrId(id);
    }


    @Override
    public List<AppUser> findList(Map<String, Object> map, SplitPageBean bean) {
        return appUserDao.findList(map, bean);
    }

    @Override
    public List<AppUnReadUser> findUnReadList(Map<String, Object> map, SplitPageBean bean) {
        return appUserDao.findUnReadList(map, bean);
    }

    @Override
    public List<AppUser> userCount(Map<String, Object> map) {
        return appUserDao.userCount(map);
    }

    @Override
    public int getCount(Map<String, Object> map) {
        return appUserDao.getCount(map);
    }

    @Override
    public AppUser getUserByCode(String code) {
        return appUserDao.getUserByCode(code);
    }

    @Override
    public List<AppUser> getInvitationCode(String invitationcode) {
        return appUserDao.getInvitationCode(invitationcode);
    }

    @Override
    public List<AppUser> findAllList() {
        return appUserDao.findAllList();
    }

    @Override
    public void upstate(Integer id, Integer state) {
        appUserDao.upstate(id, state);
        String key = String.format(RedisKeys.USER, id);
        redisUtil.del(key);
    }

    @Override
    public void onlineUpstate(Integer id, Integer state) {
        appUserDao.onlineUpstate(id, state);
    }

    @Override
    public void addMessage(Integer id, Integer state) {
        appUserDao.addMessage(id, state);
        String key = String.format(RedisKeys.USER, id);
        redisUtil.del(key);
    }

    @Override
    public void lastroomtxcode(Integer id, Integer roomtxcode) {
        appUserDao.lastroomtxcode(id, roomtxcode);
        String key = String.format(RedisKeys.USER, id);
        redisUtil.del(key);
    }

    @Override
    public AppUser findByUser(String loginname, String password) {
        return appUserDao.findByUser(loginname, password);
    }

    @Override
    public AppUser findByLoginname(String loginname) {
        return appUserDao.findByLoginname(loginname);
    }

    @Override
    public void addJindou(Integer userId, BigDecimal number) {
        appUserDao.addJindou(userId, number);
        String key = String.format(RedisKeys.USER, userId);
        redisUtil.del(key);
    }

    @Override
    public AppUser findByGooleId(String id) {
        return appUserDao.findByGooleId(id);
    }

    @Override
    public AppUser findByFaccBackId(String id) {
        return appUserDao.findByFaccBackId(id);
    }

    @Override
    public AppUser findByAppleBackId(String id) {
        return appUserDao.findByAppleBackId(id);
    }

    @Override
    public void upPassword(Integer id, String password) {
        appUserDao.upPassword(id, password);
        String key = String.format(RedisKeys.USER, id);
        redisUtil.del(key);
    }

    @Override
    public void upshengao(Integer id, String shengao, Integer shengaoid) {
        appUserDao.upshengao(id, shengao, shengaoid);
        String key = String.format(RedisKeys.USER, id);
        redisUtil.del(key);
    }

    @Override
    public void uptizhong(Integer id, String tizhong, Integer tizhongid) {
        appUserDao.uptizhong(id, tizhong, tizhongid);
        String key = String.format(RedisKeys.USER, id);
        redisUtil.del(key);
    }

    @Override
    public void upnianshouru(Integer id, String nian, Integer nianid) {
        appUserDao.upnianshouru(id, nian, nianid);
        String key = String.format(RedisKeys.USER, id);
        redisUtil.del(key);
    }

    @Override
    public void upxueli(Integer id, String xueli, Integer xueliru) {
        appUserDao.upxueli(id, xueli, xueliru);
        String key = String.format(RedisKeys.USER, id);
        redisUtil.del(key);
    }

    @Override
    public void upzhiye(Integer id, Integer zhiyecode, String zhiyename) {
        appUserDao.upzhiye(id, zhiyecode, zhiyename);
        String key = String.format(RedisKeys.USER, id);
        redisUtil.del(key);
    }

    @Override
    public void upbiaoqian(Integer id, String biaoqianid, String biaoqianname) {
        appUserDao.upbiaoqian(id, biaoqianid, biaoqianname);
        String key = String.format(RedisKeys.USER, id);
        redisUtil.del(key);
    }

    @Override
    public void upnick(Integer id, String nick) {
        appUserDao.upnick(id, nick);
//        //提现
//        appCashWithdrawalDao.updateNick(id, nick);
//        //动态评论
        appCommentDao.updateNick(id, nick);
//        //评论点赞
        appCommentDianzanDao.updateNick(id, nick);
//        //评论回复
        appCommentReplyDao.updateNick(id, nick);
//        appCommentReplyDao.updateReplyNick(id, nick);
//        //动态
        appDynamicDao.updateNick(id, nick);
//        //动态点赞
        appDynamicDao.updateNick(id, nick);
//       /* //收益明细
        appEarningsDao.updateImg(id, nick);
//        //兑换记录
//        appExchangeDao.updateNick(id, nick);
//        //粉丝
        appFansDao.updateNick(id, nick);
//        //反馈举报
        appFeedbackDao.updateNick(id, nick);
        appFeedbackDao.updateBjbNick(id, nick);
//        //关注
        appFollowDao.updateBgzNick(id, nick);
        appFollowDao.updateNick(id, nick);
//        //礼物打赏
        appGiftRewardDao.updateNick(id, nick);
        appGiftRewardDao.updateDsNick(id, nick);
//        //邀请
        appInvitationRecordDao.updateNick(id, nick);
        appInvitationRecordDao.updateSjNick(id, nick);
//        //背包
//        appKnapsackDao.updateNick(id, nick);
//        //会话
//        appNewDao.updateNick(id, nick);
//        appNewDao.updateDfNick(id, nick);
//        //签到记录
//        appQianDaoRecordDao.updateNick(id, nick);
//        //建议表
//        appSuggestDao.updateNick(id, nick);
//        //购买坐骑
        appUserDressupDao.updateNick(id, nick);
//        //用户登录
        appUserLoginRecordDao.updateNick(id, nick);
//        //访客
        appVisitorDao.updateNick(id, nick);
        appVisitorDao.updateGustNick(id, nick);
//        //钻石
        appMingXiZuanShiDao.updateNick(id, nick);
//        //金币
        appMingxiJinbiDao.updateNick(id, nick);
//        //魅力值
        appMingxiMeilizhiDao.updateNick(id, nick);
        //动态通知
        dynamicAlertDao.updateNick(id, nick);

        String key = String.format(RedisKeys.USER, id);
        redisUtil.del(key);
    }

    @Override
    public void upMysign(Integer id, String mysign) {
        appUserDao.upMysign(id, mysign);
        //关注
        appFollowDao.updateMysign(id, mysign);
        appFollowDao.updateBgzMysign(id, mysign);
        String key = String.format(RedisKeys.USER, id);
        redisUtil.del(key);
    }

    @Override
    public void upAlipay(Integer id, String name, String alipay) {
        appUserDao.upAlipay(id, name, alipay);
    }

    @Override
    public void upAddress(Integer id, String address, Integer shengid, Integer shiid, Integer areaId) {
        appUserDao.upAddress(id, address, shengid, shiid, areaId);
        String key = String.format(RedisKeys.USER, id);
        redisUtil.del(key);
    }

    @Override
    public void upbirthday(Integer id, Date birthday) {
        appUserDao.upbirthday(id, birthday);
        String key = String.format(RedisKeys.USER, id);
        redisUtil.del(key);
    }

    @Override
    @Transactional(rollbackFor = java.lang.Exception.class)
    public boolean completeMaterial(Integer id, String pic, String nicheng, Integer sex, Date shengri, String yaoqingma, String password,String packageName) {
        try {
            AppUser user = appUserDao.get(id);
            //完善资料
            appUserDao.completeMaterial(id, pic, nicheng, sex, shengri, password,packageName);
            Map<String, String> maxPrice = priceSetService.maxPriceNoCharm();
            appUserDao.updateMessagePrice(id, maxPrice.get("message"), maxPrice.get("voice"), maxPrice.get("video"));

            //邀请码存在  &&  用户未绑定上级
            if (!isNull(yaoqingma) && isNull(user.getInvitationcode())) {
                //有上级邀请码
                AppUser user1 = appUserDao.getUserByCode(yaoqingma);
                if (user1 != null) {
                    //新增邀请记录
                    AppInvitationRecord appInvitationRecord = new AppInvitationRecord();
                    appInvitationRecord.setCreatetime(new Date());
                    appInvitationRecord.setUserid(user.getId());
                    appInvitationRecord.setNick(nicheng);
                    appInvitationRecord.setPic(pic);
                    appInvitationRecord.setPhone(user.getLoginname());
                    appInvitationRecord.setSex(sex);
                    appInvitationRecord.setPuserid(user1.getId());
                    appInvitationRecord.setPphone(user1.getLoginname());
                    appInvitationRecord.setPpsex(user1.getSex());
                    appInvitationRecord.setPnick(user1.getNick());
                    appInvitationRecord.setPpic(user1.getPic());
                    appInvitationRecord.setSupermoney(0.00);
                    appInvitationRecordDao.save(appInvitationRecord);
                    //更新团队信息
                    AppInvitationRecord parentInfo = appInvitationRecordDao.getShangji(id);
                    parentInfo.setPic(pic);
                    parentInfo.setSex(sex);
                    parentInfo.setNick(nicheng);
                    appInvitationRecordDao.save(parentInfo);
                    //绑定上级
                    appUserDao.bindSuperior(id, yaoqingma);
                }
            }
            String key = String.format(RedisKeys.USER, id);
            redisUtil.del(key);
            //腾讯三方导入
            UserShiZhi shiZhi = new UserShiZhi();
            shiZhi.setNicheng(nicheng);
            shiZhi.setTouxiang(pic);
            shiZhi.setTengxuncode(user.getTengxuncode() + "");
            portraitTouXiangSet(shiZhi);
            portraitNiChengSet(shiZhi);
            return true;
        } catch (Exception e) {
            //导入失败  事务回滚
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
            return false;
        }
    }


    @Override
    public void uppic(Integer id, String pic) {
        appUserDao.uppic(id, pic);
        //提现
        appCashWithdrawalDao.updateImg(id, pic);
        //动态评论
        appCommentDao.updateImg(id, pic);
        //评论点赞
        appCommentDianzanDao.updateImg(id, pic);
        //评论回复
        appCommentReplyDao.updateImg(id, pic);
        appCommentReplyDao.updateReplyImg(id, pic);
        //动态
        appDynamicDao.updateImg(id, pic);
        //动态点赞
        appDynamicDianzanDao.updateImg(id, pic);
        //粉丝
        appFansDao.updateImg(id, pic);
        //反馈举报
        appFeedbackDao.updateBjbImg(id, pic);
        appFeedbackDao.updateImg(id, pic);
        //关注
        appFollowDao.updateBgzImg(id, pic);
        appFollowDao.updateImg(id, pic);
        //礼物打赏记录
        appGiftRewardDao.updateDsImg(id, pic);
        appGiftRewardDao.updateImg(id, pic);
        //邀请
        appInvitationRecordDao.updateImg(id, pic);
        appInvitationRecordDao.updateSjImg(id, pic);
        //背包
        appKnapsackDao.updateImg(id, pic);
        //会话
        appNewDao.updateDfImg(id, pic);
        appNewDao.updateImg(id, pic);
        //签到记录
        appQianDaoRecordDao.updateImg(id, pic);
        //购买坐骑
        appUserDressupDao.updateImg(id, pic);
        //用户登录
        appUserLoginRecordDao.updateImg(id, pic);
        //访客表
        appVisitorDao.updateGustImg(id, pic);
        appVisitorDao.updateImg(id, pic);
        //反馈
        appSuggestDao.updatePic(id, pic);
        //团队
        appInvitationRecordDao.updatePic(id, pic);
        //钻石
        appMingXiZuanShiDao.updateImg(id, pic);
        //金币
        appMingxiJinbiDao.updateImg(id, pic);
        //动态通知
        dynamicAlertDao.updatePic(id, pic);

        String key = String.format(RedisKeys.USER, id);
        redisUtil.del(key);
    }

    @Override
    public void upxingxiang(Integer id, String xxpic) {
        appUserDao.upxingxiang(id, xxpic);
        String key = String.format(RedisKeys.USER, id);
        redisUtil.del(key);
    }

    @Override
    public boolean existsNameAndIdNum(String realName, String idNum) {
        AppUser appUser = appUserDao.existsNameAndIdNum(realName, idNum);
        return appUser != null;
    }

    @Override
    public void updateRealName(Integer userId, String realName, String idNum) {
        appUserDao.updateRealName(userId, realName, idNum);
        String key = String.format(RedisKeys.USER, userId);
        redisUtil.del(key);
    }

    @Override
    public void updateEdu(Integer userId, String edu) {
        int eduStatus = 0;
        if (edu.equals("专科") || edu.equals("大专")) {
            eduStatus = 1;
        } else if (edu.equals("本科")) {
            eduStatus = 2;
        } else if (edu.equals("双学士") || edu.equals("双学位")) {
            eduStatus = 3;
        } else if (edu.equals("硕士")) {
            eduStatus = 4;
        } else if (edu.equals("博士")) {
            eduStatus = 5;
        }
        appUserDao.updateEdu(userId, eduStatus);

        String key = String.format(RedisKeys.USER, userId);
        redisUtil.del(key);
    }

    @Override
    public AppUser getTengxuncodeByUser(Integer tengxuncode) {
        return appUserDao.getTengxuncodeByUser(tengxuncode);
    }

    @Override
    public List<AppUser> getPiliangTengxuncodeByUser(String tengxuncode) {
        return appUserDao.getPiliangTengxuncodeByUser(tengxuncode);
    }

    @Override
    public List<AppUser> getPiliangYaoqingma(String yaoqingma) {
        return appUserDao.getPiliangYaoqingma(yaoqingma);
    }

    @Override
    public List<RoomMemberDto> getBatchTengxuncodeByUser(String tengxuncode, String likecha, SplitPageBean splitPage) {
        return appUserDao.getBatchTengxuncodeByUser(tengxuncode, likecha, splitPage);
    }

    @Override
    public void upzhifumima(Integer id, String paypassword) {
        appUserDao.upzhifumima(id, paypassword);
        String key = String.format(RedisKeys.USER, id);
        redisUtil.del(key);
    }

    @Override
    public String aliyunOssupload(MultipartFile file) {
        Result result = new Result();
        try {

            String name = file.getOriginalFilename();
            String suffix = name.substring(name.indexOf("."));
            String fileName = "";
            String randomName = "";
            String imgname = "";
            if (!"Yuliao".equals(suffix)) {
                randomName = UUID.randomUUID().toString().replaceAll("-", "");
                fileName = randomName + suffix;
                imgname = randomName;//图片名称（不带后缀）
            }
            Long size = file.getSize();
            // 创建OSSClient实例
            OSSClient ossClient = new OSSClient(AliyunOSSClientUtil.ENDPOINT, AliyunOSSClientUtil.ACCESSKEYID, AliyunOSSClientUtil.ACCESSKEYSECRET);
            // 上传：picturePath + uploadFile.getOriginalFilename() --> key
            ossClient.putObject(AliyunOSSClientUtil.BUCKETNAME, AliyunOSSClientUtil.KEY + fileName, new ByteArrayInputStream(file.getBytes()));
            // 关闭client
            ossClient.shutdown();
            //设置过期时间 -- 十年
            Date expiration = new Date(System.currentTimeMillis() + 3600L * 1000 * 24 * 365 * 10);
            //取出文件上传路径
            String url = ossClient.generatePresignedUrl(AliyunOSSClientUtil.BUCKETNAME, AliyunOSSClientUtil.KEY + fileName, expiration).toString();
            String aaa = url.substring(0, url.indexOf("?"));
            //aaa=aaa.replace("http://yunliaos.oss-cn-beijing.aliyuncs.com", "http://image.y-yl.com");
/*
            aaa=aaa.replace("http://","https://");
            aaa+="?x-oss-process=image/resize,w_700/format,jpg/quality,q_85";
*/
            return aaa;
        } catch (Exception e) {
            return "";
        }
    }

    /**
     * 视频上传
     */
    @Override
    public Result aliyunOssShipingUp(MultipartFile file) {
        Result result = new Result();
        try {
            String name = file.getOriginalFilename();
            String suffix = name.substring(name.lastIndexOf("."));
            String fileName = "";
            String randomName = "";
            //判断视频格式
            if (!checkMediaType(suffix)) {
                result.setCode(1002);
                result.setMsg("视频格式不正确");
                return result;
            }
            if (!"Yuliao".equals(suffix)) {
                randomName = UUID.randomUUID().toString().replaceAll("-", "");
                fileName = randomName + suffix;
            }
            Long size = file.getSize();
            // 创建OSSClient实例
            OSSClient ossClient = new OSSClient(AliyunOSSClientUtil.ENDPOINT, AliyunOSSClientUtil.ACCESSKEYID, AliyunOSSClientUtil.ACCESSKEYSECRET);
            // 上传：picturePath + uploadFile.getOriginalFilename() --> key
            ossClient.putObject(AliyunOSSClientUtil.BUCKETNAME, AliyunOSSClientUtil.KEY + fileName, new ByteArrayInputStream(file.getBytes()));
            // 关闭client
            ossClient.shutdown();
            //设置过期时间 -- 十年
            Date expiration = new Date(System.currentTimeMillis() + 3600L * 1000 * 24 * 365 * 10);
            //取出文件上传路径
            String url = ossClient.generatePresignedUrl(AliyunOSSClientUtil.BUCKETNAME, AliyunOSSClientUtil.KEY + fileName, expiration).toString();
            String aaa = url.substring(0, url.indexOf("?"));
            Map<String, String> mm = new HashMap<>(16);
            System.out.println("阿里云上传路径：" + url);
            result.setCode(0);
            result.setData(aaa);
            result.setMsg("OK");
            return result;
        } catch (Exception e) {
            result.setCode(1001);
            result.setMsg("上传失败");
            return result;
        }
    }

    /**
     * 判断视频格式是否正确
     *
     * @Param: [fileEnd 文件后缀]
     * @return: boolean
     * @Author: zhouyunyi
     * @Date: 2021/07/22
     * @Time: 16:41
     */
    private boolean checkMediaType(String fileEnd) {
        String[] suffixFile = {".mp4", ".3gp", ".avi", ".rm", ".mov", ".rmvb", ".flv"};
        Iterator<String> type = Arrays.asList(suffixFile).iterator();
        while (type.hasNext()) {
            String ext = type.next();
            if (fileEnd.equals(ext)) {
                return true;
            }
        }
        return false;
    }

    /**
     * 判断图片格式是否正确
     *
     * @Param: [fileEnd]
     * @return: boolean
     * @Author: zhouyunyi
     * @Date: 2021/07/5
     * @Time: 11:40
     */
    private boolean checkImageType(String fileEnd) {
        String[] suffixFile = {".jpg", ".png", ".jpeg", ".svg", ".JPG", ".PNG", ".JPEG", ".SVG"};
        Iterator<String> type = Arrays.asList(suffixFile).iterator();
        while (type.hasNext()) {
            String ext = type.next();
            if (fileEnd.equals(ext)) {
                return true;
            }
        }
        return false;
    }

    @Override
    public List<AppUser> getFujinRenList(Map<String, Object> paraMap, SplitPageBean splitPageBean) {
        return appUserDao.getFujinRenList(paraMap, splitPageBean);
    }

    @Override
    public List<AppUser> allList() {
        return appUserDao.allList();
    }

    @Override
    public void updateLiWu(Integer id, Integer leixing) {
        appUserDao.updateLiWu(id, leixing);
        String key = String.format(RedisKeys.USER, id);
        redisUtil.del(key);
    }

    @Override
    public void updateweizhi(Integer id, Integer leixing) {
        appUserDao.updateweizhi(id, leixing);
        String key = String.format(RedisKeys.USER, id);
        redisUtil.del(key);
    }

    @Override
    public void updatejinbi(Integer id, BigDecimal jinbi) {
        appUserDao.updatejinbi(id, jinbi);
        String key = String.format(RedisKeys.USER, id);
        redisUtil.del(key);
    }

    @Override
    public void updateZuanShi(Integer id, BigDecimal zuanshi) {
        appUserDao.updateZuanShi(id, zuanshi);
        String key = String.format(RedisKeys.USER, id);
        redisUtil.del(key);
    }

    @Override
    public void upJianZuanShi(Integer id, BigDecimal zuanshi) {
        appUserDao.upJianZuanShi(id, zuanshi);
        String key = String.format(RedisKeys.USER, id);
        redisUtil.del(key);
    }

    @Override
    public void addJinbi(Integer id, BigDecimal jinbi, String mark) {
        updatejinbi(id, jinbi);
        String key = String.format(RedisKeys.USER, id);
        redisUtil.del(key);

        AppUser user = appUserDao.get(id);

        AppMingxiJinbi zuanShi = new AppMingxiJinbi();
        zuanShi.setUserid(user.getId());
        zuanShi.setPic(user.getPic());
        zuanShi.setPhone(user.getLoginname());
        zuanShi.setNick(user.getNick());
        zuanShi.setLeixing(1);
        zuanShi.setNum(jinbi);
        zuanShi.setCreatetime(new Date());
        zuanShi.setBeizhu(mark);
        appMingxiJinbiDao.save(zuanShi);
    }

    @Override
    public void subJinbi(Integer id, BigDecimal jinbi, String mark) {
        appUserDao.upJianjinbi(id, jinbi);
        String key = String.format(RedisKeys.USER, id);
        redisUtil.del(key);

        AppUser user = appUserDao.get(id);

        AppMingxiJinbi zuanShi = new AppMingxiJinbi();
        zuanShi.setUserid(user.getId());
        zuanShi.setPic(user.getPic());
        zuanShi.setPhone(user.getLoginname());
        zuanShi.setNick(user.getNick());
        zuanShi.setLeixing(2);
        zuanShi.setNum(jinbi);
        zuanShi.setCreatetime(new Date());
        zuanShi.setBeizhu(mark);
        appMingxiJinbiDao.save(zuanShi);
    }

    @Override
    public void addDiamonds(Integer id, BigDecimal zuanshi, String mark) {
        appUserDao.updateZuanShi(id, zuanshi);
        String key = String.format(RedisKeys.USER, id);
        redisUtil.del(key);

        AppUser user = appUserDao.get(id);

        AppMingXiZuanShi mingxi = new AppMingXiZuanShi();
        mingxi.setUserid(id);
        mingxi.setPic(user.getPic());
        mingxi.setPhone(user.getLoginname());
        mingxi.setNick(user.getNick());
        mingxi.setLeixing(1);
        mingxi.setNum(zuanshi);
        mingxi.setCreatetime(new Date());
        mingxi.setBeizhu(mark);
        appMingXiZuanShiDao.saveOrUpdate(mingxi);
    }

    @Override
    public void addCharm(Integer id, Integer meili, String mark) {
        appUserDao.updatemeili(id, meili);
        String key = String.format(RedisKeys.USER, id);
        redisUtil.del(key);

        AppUser user = appUserDao.get(id);

        //增加魅力值明细
        AppMingxiMeilizhi meilizhi = new AppMingxiMeilizhi();
        meilizhi.setUserid(id);
        meilizhi.setPic(user.getPic());
        meilizhi.setPhone(user.getLoginname());
        meilizhi.setNick(user.getNick());
        meilizhi.setLeixing(1);
        meilizhi.setNum(meili);
        meilizhi.setCreatetime(new Date());
        meilizhi.setBeizhu(mark);
        appMingxiMeilizhiDao.save(meilizhi);
    }

    @Override
    public void updatemeili(Integer id, Integer meili) {
        appUserDao.updatemeili(id, meili);
        String key = String.format(RedisKeys.USER, id);
        redisUtil.del(key);
    }

    @Override
    public void dongtaiNewUpdate(Integer id) {
        appUserDao.dongtaiNewUpdate(id);
        String key = String.format(RedisKeys.USER, id);
        redisUtil.del(key);
    }

    @Override
    public void dongtaiallUpdate(Integer id, Integer leixing) {
        appUserDao.dongtaiallUpdate(id, leixing);
        String key = String.format(RedisKeys.USER, id);
        redisUtil.del(key);
    }

    @Override
    public void updateLeijiChongzhi(Integer id, BigDecimal money) {
        appUserDao.updateLeijiChongzhi(id, money);
        String key = String.format(RedisKeys.USER, id);
        redisUtil.del(key);
    }

    @Override
    public List<AppUser> getPiliang(String arr) {
        return appUserDao.getPiliang(arr);
    }

    @Override
    public void familyPunchIn(int i, Integer id) {
        appUserDao.familyPunchIn(i, id);
        String key = String.format(RedisKeys.USER, id);
        redisUtil.del(key);
    }

    @Override
    public void guanzhuUpdate(Integer id, Integer leixing) {
        appUserDao.guanzhuUpdate(id, leixing);
        String key = String.format(RedisKeys.USER, id);
        redisUtil.del(key);
    }

    @Override
    public void roomCollectUpdate(Integer id, Integer leixing) {
        appUserDao.roomCollectUpdate(id, leixing);
        String key = String.format(RedisKeys.USER, id);
        redisUtil.del(key);
    }

    @Override
    public void fansnumallUpdate(Integer id, Integer leixing) {
        appUserDao.fansnumallUpdate(id, leixing);
        String key = String.format(RedisKeys.USER, id);
        redisUtil.del(key);
    }

    @Override
    public void fensiNewUpdate(Integer id) {
        appUserDao.fensiNewUpdate(id);
        String key = String.format(RedisKeys.USER, id);
        redisUtil.del(key);
    }

    @Override
    public void fensiNewClear(Integer id) {
        appUserDao.fensiNewClear(id);
        String key = String.format(RedisKeys.USER, id);
        redisUtil.del(key);
    }

    @Override
    public void updateLonAndLat(Integer id, String address, String addressdetail, String lon, String lat) {
        if(ObjectUtil.isNotEmpty(lat)){
            try {
                String latLon = lon + "," + lat;
//                String latLon = "116.568707,40.001839";//测试的北京市
                String url = "https://restapi.amap.com/v3/geocode/regeo?key=c340130cecf55efbf4b1ad98d39b13ff&location="+latLon;
                DefaultHttpClient httpClient = new DefaultHttpClient();
                HttpGet httpPost = new HttpGet(url);
                HttpResponse response = httpClient.execute(httpPost);
                String strResult = EntityUtils.toString(response.getEntity(), "utf-8");
                org.json.JSONObject object = new org.json.JSONObject(strResult);
                org.json.JSONObject regeocode = object.getJSONObject("regeocode");
                org.json.JSONObject addressComponent = regeocode.getJSONObject("addressComponent");
                String province = addressComponent.getString("province");
                address = province;//防止如北京市这种没有city
                String city = addressComponent.getString("city");
                address = city;
            } catch (Exception e) {
            }
        }
        appUserDao.updateLonAndLat(id, address, address, lon, lat);

        String key = String.format(RedisKeys.USER, id);
        redisUtil.del(key);
    }

    @Override
    @Transactional(rollbackFor = java.lang.Exception.class)
    public boolean registeredUser(String phone, String password, String invitationcode, String mobileSpec,String packageName) {
        try {
            Integer usercode = Integer.valueOf(RandomUtil.eightUserID());
            Integer txcode = Integer.valueOf(RandomUtil.eightUserID9());
            Object yaoqingma = RandomUtil.getInstance().generateXxString(6);
            //添加用户信息
            AppUser user = new AppUser();
            user.setLoginname(phone);
            user.setPassword(password);
            user.setUsercode(usercode);
            user.setCode(yaoqingma.toString());
            user.setTengxuncode(txcode);
            user.setPic("https://yunliaos.oss-cn-beijing.aliyuncs.com/image/default_head.png");
            user.setCreatetime(new Date());
            user.setPackageName(packageName);
            AppUser parentUser = appUserDao.getUserByCode(invitationcode);
//            if (parentUser != null) {
//                user.setInvitationcode(invitationcode);
//            }
            user.setInvitationcode(invitationcode);
            user.setStates(1);
            user.setEndonlinetime(new Date());
            user.setNick("" + usercode);
            user.setBirthday(new Date());
            user.setSex(3);
            user.setMessagealert(1);

            //默认能设置的最高价格
            Map<String, String> maxPrice = priceSetService.maxPriceNoCharm();
            user.setMessagePrice(maxPrice.get("message"));
            user.setVoiceStatus(1);
            user.setVoicePrice(maxPrice.get("voice"));
            user.setVideoStatus(1);
            user.setVideoPrice(maxPrice.get("video"));
            user.setDiamonds(BigDecimal.ZERO);
            user.setJinbi(BigDecimal.ZERO);
            user.setMobileSpec(mobileSpec);
            appUserDao.save(user);
            //添加邀请人
            if (parentUser != null) {
                AppSetup setup = appSetupDao.get();
                //新增邀请记录
                AppInvitationRecord appInvitationRecord = new AppInvitationRecord();
                appInvitationRecord.setCreatetime(new Date());
                appInvitationRecord.setUserid(user.getId());
                appInvitationRecord.setNick(user.getNick());
                appInvitationRecord.setPic(user.getPic());
                appInvitationRecord.setPhone(user.getLoginname());
                appInvitationRecord.setSex(user.getSex());
                appInvitationRecord.setPuserid(parentUser.getId());
                appInvitationRecord.setPphone(parentUser.getLoginname());
                appInvitationRecord.setPpsex(parentUser.getSex());
                appInvitationRecord.setPnick(parentUser.getNick());
                appInvitationRecord.setPpic(parentUser.getPic());
                appInvitationRecord.setSupermoney(setup.getSuperreward().doubleValue());
                appInvitationRecord.setStatus(1);
                appInvitationRecordDao.save(appInvitationRecord);
            }
            appAuthUserService.addUserAuth(user.getId(), ClientConstants.UserAuth.MOBILE_AUTH, null, null, null, null);

            AppUserSetting setting = new AppUserSetting();
            setting.setHiddenMyGuard(0);
            setting.setHiddenGuardMe(0);
            setting.setHiddenArea(1);
            setting.setHiddenRank(0);
            setting.setUserId(user.getId());
            appUserSettingDao.add(setting);
            //腾讯导入
            int errcode = TxIm.accountImport(txcode, "" + usercode, "https://yunliaos.oss-cn-beijing.aliyuncs.com/image/default_head.png");
            //判断是否成功导入
            if (errcode == Constants.TX_ERRCODED_SUCESS) {
                systemAlertService.hello(txcode);
                return true;
            } else {
                //导入失败  事务回滚
                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                return false;
            }
        } catch (Exception e) {
            e.printStackTrace();
            //导入失败  事务回滚
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
            return false;
        }
    }

    @Override
    public void update(AppUser user) {
        appUserDao.update(user);
        String key = String.format(RedisKeys.USER, user.getId());
        redisUtil.del(key);
    }

    @Override
    public void saveMessagePrice(Integer userId, Integer type, String price) {
        appUserDao.saveMessagePrice(userId, type, price);
        String key = String.format(RedisKeys.USER, userId);
        redisUtil.del(key);
    }

    @Override
    public void updateMessageStatus(Integer userId, Integer type) {
        AppUser user = appUserDao.get(userId);

        if (type == 1) {
            if (user.getVoiceStatus() == null || user.getVoiceStatus() == 0) {
                appUserDao.openVoiceStatus(userId);
            } else {
                appUserDao.closeVoiceStatus(userId);
            }
        } else if (type == 2) {
            if (user.getVideoStatus() == null || user.getVideoStatus() == 0) {
                appUserDao.openVideoStatus(userId);
            } else {
                appUserDao.closeVideoStatus(userId);
            }
        }
        String key = String.format(RedisKeys.USER, userId);
        redisUtil.del(key);
    }

    @Override
    public Boolean isEnough(Integer userId, BigDecimal diamonds) {
        AppUser user = appUserDao.get(userId);
        return user.getDiamonds().compareTo(diamonds) >= 0;
    }

    @Override
    public Boolean isEnoughGold(Integer userId, BigDecimal jinbi) {
        AppUser user = appUserDao.get(userId);
        return user.getJinbi().compareTo(jinbi) > 0;
    }


    /**
     * 随机匹配夫妻相用户
     *
     * @param sex
     * @param biaoqianid
     * @param lon
     * @param lat
     * @return
     */
    @Override
    public AppUser randomMatchUser(Integer sex, String biaoqianid, String lon, String lat) {
        if (biaoqianid != null) {
            AppUser appUser = appUserDao.randomMatchUserByBiaoqian(sex, biaoqianid);
            if (appUser != null) {
                return appUser;
            }
        }
        if (lon != null && lat != null) {
            AppUser appUser1 = appUserDao.randomMatchUserBylonAndLat(lon, lat, sex);
            if (appUser1 != null) {
                return appUser1;
            }
        }
        AppUser appUser2 = appUserDao.randomGetUser(sex);
        if (appUser2 != null) {
            return appUser2;
        } else {
            return null;
        }
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<AppUser> sameCityMatch(Integer userId, Integer sex, Integer shiid, Integer matchNum, BigDecimal payDiamonds, String textContent) {
        try {
            List<AppUser> appUsers = appUserDao.sameCityMatch(sex, shiid, matchNum);
            AppUser appUserInfo = appUserDao.get(userId);
            if (appUsers != null && appUsers.size() > 0) {
                for (AppUser appUser : appUsers) {
                    boolean b = TxIm.sendUserMsgNew(appUser.getTengxuncode(), appUserInfo.getTengxuncode(), textContent, "TIMTextElem");
                    if (!b) {
                        throw new Exception("发送信息失败");
                    } else {
                        appUserDao.upJianZuanShi(userId, payDiamonds);
                        AppMingXiZuanShi appMingXiZuanShi = new AppMingXiZuanShi();
                        appMingXiZuanShi.setUserid(userId);
                        appMingXiZuanShi.setPic(appUserInfo.getPic());
                        appMingXiZuanShi.setPhone(appUserInfo.getLoginname());
                        appMingXiZuanShi.setNick(appUserInfo.getNick());
                        appMingXiZuanShi.setLeixing(2);
                        appMingXiZuanShi.setNum(payDiamonds);
                        appMingXiZuanShi.setCreatetime(new Date());
                        appMingXiZuanShi.setBeizhu("搭讪" + appUser.getNick() + "消耗" + payDiamonds + "钻石");
                        appMingXiZuanShiDao.saveOrUpdate(appMingXiZuanShi);
                    }
                }
                return appUsers;
            } else {
                List<AppUser> appUsers1 = appUserDao.sameCityRandomMatch(sex, matchNum);
                if (appUsers1 != null && appUsers1.size() > 0) {
                    for (AppUser appUser : appUsers1) {
                        boolean b = TxIm.sendUserMsgNew(appUser.getTengxuncode(), appUserInfo.getTengxuncode(), textContent, "TIMTextElem");
                        if (!b) {
                            throw new Exception("发送信息失败");
                        } else {
                            appUserDao.upJianZuanShi(userId, payDiamonds);
                            AppMingXiZuanShi appMingXiZuanShi = new AppMingXiZuanShi();
                            appMingXiZuanShi.setUserid(userId);
                            appMingXiZuanShi.setPic(appUserInfo.getPic());
                            appMingXiZuanShi.setPhone(appUserInfo.getLoginname());
                            appMingXiZuanShi.setNick(appUserInfo.getNick());
                            appMingXiZuanShi.setLeixing(2);
                            appMingXiZuanShi.setNum(payDiamonds);
                            appMingXiZuanShi.setCreatetime(new Date());
                            appMingXiZuanShi.setBeizhu("搭讪" + appUser.getNick() + "消耗" + payDiamonds + "钻石");
                            appMingXiZuanShiDao.saveOrUpdate(appMingXiZuanShi);
                        }
                    }
                    return appUsers;
                }
            }
        } catch (Exception e) {
            logger.error("同城匹配异常：", e);
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
        }

        return null;
    }

    @Override
    public AppUser findUserByThirdToken(String type, String token) {
        return appUserDao.findUserByThirdToken(type, token);
    }

    @Override
    public void updateUserThirdToken(Integer userId, String type, String token) {
        appUserDao.updateUserThirdToken(userId, type, token);
        String key = String.format(RedisKeys.USER, userId);
        redisUtil.del(key);
    }


    @Override
    @Transactional(rollbackFor = java.lang.Exception.class)
    public boolean addUserThirdToken(String phone, String thirdToken, String type) {
        try {
            Random random = new Random();
            //获取usercode
            long userCodeSize = redisUtil.lGetListSize("chi:usercode");
            int userCodeIndex = random.nextInt((int) userCodeSize);
            Integer usercode = Integer.valueOf(redisUtil.lGetIndex("chi:usercode", userCodeIndex).toString());
            redisUtil.lRemove("chi:usercode", 1, usercode + "");
            //获取腾讯code
            long txCodeSize = redisUtil.lGetListSize("chi:txcode");
            int txCodeIndex = random.nextInt((int) txCodeSize);
            Integer txcode = Integer.valueOf(redisUtil.lGetIndex("chi:txcode", txCodeIndex).toString());
            redisUtil.lRemove("chi:txcode", 1, txcode + "");
            //生成邀请码
            long yaoqingmaSize = redisUtil.lGetListSize("chi:yaoqingma");
            int yaoqingmaIndex = random.nextInt((int) yaoqingmaSize);
            Object yaoqingma = redisUtil.lGetIndex("chi:yaoqingma", yaoqingmaIndex);
            redisUtil.lRemove("chi:yaoqingma", 1, yaoqingma);
            //添加用户信息
            AppUser user = new AppUser();
            user.setLoginname(phone);
            user.setPassword("");
            user.setUsercode(usercode);
            user.setCode(yaoqingma.toString());
            user.setTengxuncode(txcode);
            user.setPic("https://yunliaos.oss-cn-beijing.aliyuncs.com/image/default_head.png");
            user.setCreatetime(new Date());
            user.setStates(1);
            user.setEndonlinetime(new Date());
            user.setNick("" + usercode);
            user.setBirthday(new Date());
            user.setSex(3);
            user.setMessagealert(1);
            if (type.equals("qq")) {
                user.setQqopenid(thirdToken);
            } else if (type.equals("weixin")) {
                user.setWeixinopenid(thirdToken);
            } else if (type.equals("apple")) {
                user.setAppleId(thirdToken);
            }

            //默认能设置的最高价格
            Map<String, String> maxPrice = priceSetService.maxPriceNoCharm();
            user.setMessagePrice(maxPrice.get("message"));
            user.setVoiceStatus(1);
            user.setVoicePrice(maxPrice.get("voice"));
            user.setVideoStatus(1);
            user.setVideoPrice(maxPrice.get("video"));
            user.setDiamonds(BigDecimal.ZERO);
            user.setJinbi(BigDecimal.ZERO);
            appUserDao.save(user);
            appAuthUserService.addUserAuth(user.getId(), ClientConstants.UserAuth.MOBILE_AUTH, null, null, null, null);

            AppUserSetting setting = new AppUserSetting();
            setting.setHiddenMyGuard(0);
            setting.setHiddenGuardMe(0);
            setting.setHiddenArea(1);
            setting.setHiddenRank(0);
            setting.setUserId(user.getId());
            appUserSettingDao.add(setting);
            //腾讯导入
            int errcode = TxIm.accountImport(txcode, "" + usercode, "https://yunliaos.oss-cn-beijing.aliyuncs.com/image/default_head.png");
            //判断是否成功导入
            if (errcode == Constants.TX_ERRCODED_SUCESS) {
                systemAlertService.hello(txcode);
                return true;
            } else {
                //导入失败  事务回滚
                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                return false;
            }
        } catch (Exception e) {
            e.printStackTrace();
            //导入失败  事务回滚
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
            return false;
        }
    }

    @Override
    public List<AppUser> findUserListBySex(Integer sex) {
        return appUserDao.findUserListBySex(sex);
    }

    @Override
    public List<AppUser> findUserListByShuJuAndSex(Integer sex) {
        return appUserDao.findUserListByShuJuAndSex(sex);
    }

    @Override
    public boolean isVip(Integer userId) {
        AppUser appUser = this.get(userId);
        if (appUser.getVipEndDate() != null) {
            return TimeUtils.afterNow(appUser.getVipEndDate());
        }
        return false;
    }

    @Override
    public Map<String, Object> isVipMap(Integer userId) {
        Map<String, Object> data = new HashMap<>();
        data.put("isVip", 0);
        data.put("vipEndDate", "");
        AppUser appUser = this.get(userId);
        if (appUser.getVipEndDate() != null) {
            data.put("isVip", TimeUtils.afterNow(appUser.getVipEndDate())? 1: 0);
            data.put("vipEndDate", DatesUtil.dateToStr(appUser.getVipEndDate(), "yyyy-MM-dd"));
        }
        return data;
    }

    @Override
    public void openYoung(Integer userId, String pass) {
        AppUser user = this.get(userId);
        user.setYoungMode(1);
        user.setYoungModePass(pass);

        this.update(user);

        String key = String.format(RedisKeys.USER, userId);
        redisUtil.del(key);
    }

    @Override
    public void closeYoung(Integer userId) {
        appUserDao.closeYoung(userId);
        String key = String.format(RedisKeys.USER, userId);
        redisUtil.del(key);
    }

    @Override
    public List<AppUser> findOnlineUserListBySex(Integer sex, String ignoreUserIds, int limit) {
        return appUserDao.findOnlineUserListBySex(sex, ignoreUserIds, limit);
    }

    @Override
    public List<AppUser> findOnlineUser(Integer online) {
        return appUserDao.findOnlineUser(online);
    }


    @Override
    public void updateMobileSpec(Integer userId, String mobileSpec) {

        appUserDao.updateMobileSpec(userId, mobileSpec);
    }

    @Override
    public void upweChatNum(Integer id, String weChatNum) {
        appUserDao.upweChatNum(id,weChatNum);
    }

    @Override
    public void updateOnlinestatus(Integer userId, Integer onlinestatus) {
        appUserDao.updateOnline(userId, onlinestatus);
    }

    @Override
    public void upstateWindowTicket(Integer id) {
        appUserDao.upstateWindowTicket(id);
    }

    @Override
    public List<AppUser> isBlackList() {

        List<AppUser> users = appUserDao.isBlackList();

        return users;
    }

    @Override
    public List<AppUser> getUserInfoSearch(String loginNames) {


        return appUserDao.getUserInfoSearch(loginNames);
    }

    @Override
    public List<AppUser> findUpDataList(Integer sex, Integer isReal) {
        return appUserDao.findUpDataList(sex,isReal);
    }

    @Override
    public List<AppUser> findUserListByTxcodes(String txcodes) {
        return appUserDao.findUserListByTxcodes(txcodes);
    }


}
